// 形象进度详情

<template>
    <f7-page class="detail">
        <f7-navbar>
            <f7-nav-left>
                <f7-link back
                         icon-material="arrow_back"></f7-link>
            </f7-nav-left>
            <f7-nav-title>形象进度</f7-nav-title>
            <f7-nav-right>
                <f7-icon f7="house"
                         @click.native="fnToHome()"></f7-icon>
            </f7-nav-right>
        </f7-navbar>

        <van-notice-bar background="#fff"
                        color="#345">
            <f7-icon solt="left-icon"
                     color="#3385ff"
                     f7="layers_alt_fill"></f7-icon>
            <span>{{controlData.engineeInfo.engineeName}}</span>
        </van-notice-bar>

        <f7-list media-list>
            <f7-list-item>
                <div class="list-item-content">
                    <label>最新形象进度：</label>
                    <span>{{models.model.progressName}}</span>
                </div>
            </f7-list-item>

            <f7-list-item>
                <div class="list-item-content">
                    <van-field v-model="models.model.content"
                               type="textarea"
                               border
                               readonly
                               placeholder="当前施工阶段详情信息" />
                </div>
            </f7-list-item>

            <f7-list-item>
                <div class="list-item-content">
                    <f7-picture-upload disabled
                                       :params="{type:'attach',dataKey: models.model.caseId, bizType: 'progress'}"></f7-picture-upload>
                </div>
            </f7-list-item>
        </f7-list>

        <f7-list media-list
                 class="space-between">
            <f7-list-item>
                <div class="list-item-content">
                    <label>登记人</label>
                    <span>{{models.model.createUserName}}</span>
                </div>
            </f7-list-item>
            <f7-list-item>
                <div class="list-item-content">
                    <label>登记单位</label>
                    <span>{{models.model.createOrgName}}</span>
                </div>
            </f7-list-item>
            <f7-list-item>
                <div class="list-item-content">
                    <label>登记日期</label>
                    <span>{{models.model.createTime}}</span>
                </div>
            </f7-list-item>
        </f7-list>

        <f7-list media-list
                 v-if="pageAction == 'view'"
                 class="space-between">
            <f7-list-item>
                <div class="list-item-content">
                    <label>审核人</label>
                    <span>{{models.model.auditUserName}}</span>
                </div>
            </f7-list-item>
            <f7-list-item>
                <div class="list-item-content">
                    <label>审核结果</label>
                    <span>{{models.model.statusText}}</span>
                </div>
            </f7-list-item>
            <f7-list-item>
                <div class="list-item-content">
                    <label>审核意见</label>
                    <span>{{opinion}}</span>
                </div>
            </f7-list-item>
            <f7-list-item>
                <div class="list-item-content">
                    <label>审核单位</label>
                    <span>{{models.model.auditOrgName}}</span>
                </div>
            </f7-list-item>
            <f7-list-item>
                <div class="list-item-content">
                    <label>审核日期</label>
                    <span>{{models.model.auditTime}}</span>
                </div>
            </f7-list-item>
        </f7-list>

        <template v-if="pageAction != 'view'">
            <f7-toolbar position="bottom"
                        v-has="'project:progress:save'"
                        no-shadow
                        class="fff">
                <f7-button fill
                           class="submit-btn red"
                           @click="fnSubmit(3)">不通过</f7-button>
                <f7-button fill
                           class="submit-btn"
                           @click="fnSubmit(2)">通过</f7-button>
            </f7-toolbar>
        </template>

        <!-- 审核意见 -->
        <v-popup-opinion v-model="showoPinion"
                         :selectUser="selectUser"
                         @save="emitSave">
        </v-popup-opinion>
        <!-- 审核意见 end -->
    </f7-page>
</template>

<script>
import controller from "@/libs/framework/workflowController"

export default class instance extends controller {
    onBeforeInit () {
        this.urls = {
            model: "/project/progress/getWorkflowViewModel"
        }
    }
    mixin () {
        return {
            data () {
                return {
                    controlData: {
                        // 形象进度枚举
                        progressEnums: [],
                        // 项目信息
                        engineeInfo: {},
                        workflow: []
                    },
                    models: {
                        model: {}
                    },
                    selectUser: {
                        selectComment: null,
                        comment: null,
                        comments: [],
                        tran: [],
                        activity: "",
                        users: [],
                    },
                    // 审核意见的显示
                    showoPinion: false
                }
            },
            methods: {
                fnSubmit (status) {
                    this.models.model.status = status
                    this.showoPinion = true
                },
                // 提交
                emitSave () {
                    this.send()
                }
            },
            computed: {
                opinion () {
                    if (this.controlData.workflow && this.controlData.workflow.history && this.controlData.workflow.history.length > 0) {
                        let target = this.controlData.workflow.history.findLast(item => item.taskCode == 'usertask2')

                        if (target) {
                            return target.opinionText
                        } else {
                            return ''
                        }
                    } else {
                        return ''
                    }
                }
            }
        }
    }
}
</script>

<style lang="less" scoped>
@deep: ~">>>";

.detail {
    .list {
        margin: 10px 0;

        @{deep}.pic_upload {
            padding: 0;
        }
    }

    @{deep}.van-field {
        padding: 0;

        .van-field__control {
            font-size: 14px;
        }

        textarea {
            padding: 10px;
            border: 1px solid #dbdbdb;
            border-radius: 4px;
        }
    }

    .list-item-content {
        display: flex;
        font-size: 14px;

        > label {
            width: 44%;
            line-height: 18px;
        }

        > span {
            line-height: 18px;
        }
    }

    .space-between {
        .list-item-content {
            display: flex;
            justify-content: space-between;
            font-size: 14px;

            > label {
                width: 38%;
                line-height: 18px;
                color: #888;
            }

            > span {
                line-height: 18px;
                text-align: right;
            }
        }
    }
}
</style>
